{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Prediction (out of sample)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import statsmodels.api as sm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Artificial data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "nsample = 50\n",
    "sig = 0.25\n",
    "x1 = np.linspace(0, 20, nsample)\n",
    "X = np.column_stack((x1, np.sin(x1), (x1-5)**2))\n",
    "X = sm.add_constant(X)\n",
    "beta = [5., 0.5, 0.5, -0.02]\n",
    "y_true = np.dot(X, beta)\n",
    "y = y_true + sig * np.random.normal(size=nsample)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Estimation "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                      y   R-squared:                       0.981\n",
      "Model:                            OLS   Adj. R-squared:                  0.979\n",
      "Method:                 Least Squares   F-statistic:                     776.7\n",
      "Date:                Tue, 24 Dec 2019   Prob (F-statistic):           2.16e-39\n",
      "Time:                        15:01:37   Log-Likelihood:                -3.7729\n",
      "No. Observations:                  50   AIC:                             15.55\n",
      "Df Residuals:                      46   BIC:                             23.19\n",
      "Df Model:                           3                                         \n",
      "Covariance Type:            nonrobust                                         \n",
      "==============================================================================\n",
      "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "const          4.9682      0.093     53.580      0.000       4.782       5.155\n",
      "x1             0.5084      0.014     35.549      0.000       0.480       0.537\n",
      "x2             0.5663      0.056     10.074      0.000       0.453       0.679\n",
      "x3            -0.0207      0.001    -16.522      0.000      -0.023      -0.018\n",
      "==============================================================================\n",
      "Omnibus:                        1.046   Durbin-Watson:                   2.084\n",
      "Prob(Omnibus):                  0.593   Jarque-Bera (JB):                0.975\n",
      "Skew:                          -0.149   Prob(JB):                        0.614\n",
      "Kurtosis:                       2.384   Cond. No.                         221.\n",
      "==============================================================================\n",
      "\n",
      "Warnings:\n",
      "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
     ]
    }
   ],
   "source": [
    "olsmod = sm.OLS(y, X)\n",
    "olsres = olsmod.fit()\n",
    "print(olsres.summary())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## In-sample prediction"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 4.44952544  4.96302393  5.43267859  5.8276256   6.12813973  6.32887512\n",
      "  6.43974365  6.48428638  6.49580587  6.51189462  6.56825878  6.69285168\n",
      "  6.9012812   7.19424546  7.55741808  7.96380198  8.37816495  8.76282816\n",
      "  9.08385671  9.31663503  9.44991116  9.48764539  9.44835964  9.36209431\n",
      "  9.26547274  9.19568415  9.18437348  9.25244226  9.40661454  9.63833215\n",
      "  9.92516079 10.23447589 10.52882276 10.77207031 10.93534723 11.00178552\n",
      " 10.96929182 10.85089135 10.67258793 10.46909157 10.27811578 10.13418128\n",
      " 10.06294442 10.07698182 10.17372417 10.33587827 10.53426832 10.73262937\n",
      " 10.89356559 10.98469428]\n"
     ]
    }
   ],
   "source": [
    "ypred = olsres.predict(X)\n",
    "print(ypred)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create a new sample of explanatory variables Xnew, predict and plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[10.97001339 10.806745   10.51709796 10.15168341  9.77712346  9.45973971\n",
      "  9.24931544  9.16690693  9.19968816  9.30409101]\n"
     ]
    }
   ],
   "source": [
    "x1n = np.linspace(20.5,25, 10)\n",
    "Xnew = np.column_stack((x1n, np.sin(x1n), (x1n-5)**2))\n",
    "Xnew = sm.add_constant(Xnew)\n",
    "ynewpred =  olsres.predict(Xnew) # predict out of sample\n",
    "print(ynewpred)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot comparison"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXEAAAD6CAYAAABXh3cLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xd4k+XXwPHv3Z0CpYzKKFNlD0HKEpCiiChDlshShsBPfUFARcAFuKiKiIKCbGSJshURZRSQXWQoshQZLSBllNFB1/3+kbaUkkKbJn0yzue6etGmz5OcJOT0fs69lNYaIYQQzsnD6ACEEEJYT5K4EEI4MUniQgjhxCSJCyGEE5MkLoQQTkySuBBCODFJ4kII4cQkiQshhBOTJC6EEE7My94PULx4cV2hQgV7P4wQQriUPXv2XNBaB93tOLsn8QoVKhAREWHvhxFCCJeilDqZk+OknCKEEE5MkrgQQjgxSeJCCOHE7F4TtyQpKYnIyEgSEhKMeHiRA35+fpQpUwZvb2+jQxFC3IEhSTwyMpJChQpRoUIFlFJGhCDuQGvNxYsXiYyMpGLFikaHI4S4A0OSeEJCgiRwB6aUolixYkRHRxsdilNZsTeKT9Ye4UxMPKUDTQx/vAod6gYbHZZwcYYkcUASuIOT9yd3VuyNYtSyP4hPSgEgKiaeUcv+AJBELuxKOjaFsIFP1h7JS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ABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "fig, ax = plt.subplots()\n",
    "ax.plot(x1, y, 'o', label=\"Data\")\n",
    "ax.plot(x1, y_true, 'b-', label=\"True\")\n",
    "ax.plot(np.hstack((x1, x1n)), np.hstack((ypred, ynewpred)), 'r', label=\"OLS prediction\")\n",
    "ax.legend(loc=\"best\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Predicting with Formulas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using formulas can make both estimation and prediction a lot easier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from statsmodels.formula.api import ols\n",
    "\n",
    "data = {\"x1\" : x1, \"y\" : y}\n",
    "\n",
    "res = ols(\"y ~ x1 + np.sin(x1) + I((x1-5)**2)\", data=data).fit()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We use the `I` to indicate use of the Identity transform. Ie., we do not want any expansion magic from using `**2`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Intercept           4.968160\n",
       "x1                  0.508361\n",
       "np.sin(x1)          0.566318\n",
       "I((x1 - 5) ** 2)   -0.020745\n",
       "dtype: float64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.params"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now we only have to pass the single variable and we get the transformed right-hand side variables automatically"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    10.970013\n",
       "1    10.806745\n",
       "2    10.517098\n",
       "3    10.151683\n",
       "4     9.777123\n",
       "5     9.459740\n",
       "6     9.249315\n",
       "7     9.166907\n",
       "8     9.199688\n",
       "9     9.304091\n",
       "dtype: float64"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "res.predict(exog=dict(x1=x1n))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
